def get_lines(path, sub_str):
    f = open(path, encoding='gb18030', errors='ignore')
    lines = f.readlines()

    from copy import deepcopy
    lines_len = deepcopy(len(lines))
    print('searching...')
    for i in range(lines_len):
        if sub_str in lines[0]:
            print(lines[0])
            return lines

        del lines[0]


def visit_lines(lines, step):
    for i in range(0, len(lines), step):
        input('')  # 输入回车展示下一页
        for j in range(step):
            value = lines[i + j]
            if value != '\n':
                print(value)


if __name__ == '__main__':
    # txt文件路径
    txt_path = '神秘复苏.txt'
    # 开始阅读的内容
    s = '这家伙当初打不过自己'
    # 每次显示的行数
    n = 5
    visit_lines(get_lines(txt_path, s), n)
